package com.feeling.oafeeling.pojo;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.Set;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.ToString;


/**
 * 用户对象 sys_user
 * 
 * 
 */
@Data
@ToString
@TableName("sys_user")
public class SysUser
{
    private static final long serialVersionUID = 1L;

    /** 用户ID */
    private Long userId;

    /** 部门ID */
    private Long deptId;

    /** 部门名称 */
    @TableField(select = false)
    private String deptName;

    @TableField(select = false)
    private Integer total;

    /** 用户账号 */
    private String userName;

    /** 用户昵称 */
    private String nickName;

    /** 用户邮箱 */
    private String email;

    /** 手机号码 */
    private String phonenumber;

    /** 用户性别 */
    private String sex;

    /** 用户头像 */
    private String avatar;

    /** 密码 */
    private String password;

    /** 角色组 */
//    private Long[] roleIds;

    /** 状态 */
    private Integer status;

    /** 删除标记 */
    private Integer delFlag;

    /** 最后登录IP */
    private String loginIp;

    /** 最后登录时间 */
    private Date loginDate;

    @TableField(select = false,exist = false)
    private String roleId;

    @TableField(value = "create_by",fill = FieldFill.INSERT)
    private String createBy;

    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @TableField(value = "update_by",fill = FieldFill.INSERT_UPDATE)
    private String updateBy;

    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    /** 是否第一次登录 */
    @TableField(select = false)
    private Boolean loginState;

    /**
     * 权限列表
     */
    @TableField(select = false)
    private SysRole role;
    @TableField(select = false)
    private Set<String> permissions;

    public boolean isAdmin()
    {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId)
    {
        return userId != null && 1L == userId;
    }
}
